package nc.tb.form;

import nc.tb.cube.cell.DataCell;
import nc.tb.pub.NtbFormula;
import nc.tb.report.CellWrap;

import com.ufsoft.table.Cell;
import com.ufsoft.table.CellPosition;

public class CellPropGetter {
	
	public static String getFormulaByType(Cell ic, int type){
		if(ic == null){
			return null;
		}
		CellWrap cw = (CellWrap) ic.getExtFmt("tb");
		if(cw == null){
			return null;
		}
		NtbFormula ntbFormula = cw.getAxisFormula();
		if(ntbFormula == null){
			return null;
		}
		return ntbFormula.getFormula(type);
	}
	
	public static NtbFormula getFormula(Cell ic){
		if(ic == null){
			return null;
		}
		CellWrap cw = (CellWrap) ic.getExtFmt("tb");
		if(cw == null){
			return null;
		}
		return cw.getAxisFormula();
		
	}
	
	public static DataCell getDataCell(Cell ic){
		if(ic == null){
			return null;
		}
		CellWrap cw = (CellWrap) ic.getExtFmt("tb");
		if(cw == null){
			return null;
		}
		return cw.getDataCell();
	}
	
	public static CellPosition getCellPosition(Cell ic){
		return CellPosition.getInstance(ic.getRow(), ic.getCol());
	}
	
	
}
